<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="隧道名称" prop="tunnelName">
        <el-input
          v-model="queryParams.tunnelName"
          placeholder="请输入隧道名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="道路名称" prop="roadName">
        <el-input
          v-model="queryParams.roadName"
          placeholder="请输入道路名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="里程桩号" prop="mileageNumber">
        <el-input
          v-model="queryParams.mileageNumber"
          placeholder="请输入里程桩号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设施名称" prop="facilityName">
        <el-input
          v-model="queryParams.facilityName"
          placeholder="请输入设施名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="检查日期" prop="inspectionDate">
        <el-date-picker clearable
                        v-model="queryParams.inspectionDate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择检查日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['civil:emergencycheck:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['civil:emergencycheck:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['civil:emergencycheck:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['civil:emergencycheck:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="checkList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="编号" align="center" prop="emergencyCheckId" />
      <el-table-column label="道路名称" align="center" prop="roadName" />
      <el-table-column label="隧道名称" align="center" prop="tunnelName" />
      <el-table-column label="里程桩号" align="center" prop="mileageNumber" />
      <el-table-column label="设施名称" align="center" prop="facilityName" />
      <el-table-column label="状况值" align="center" prop="positionNumber" />
      <el-table-column label="检查人员" align="center" prop="inspection" />
      <el-table-column label="本次检查日期" align="center" prop="inspectionDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.inspectionDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作"
                       align="center"
                       width="200"
                       class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['civil:emergencycheck:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['civil:emergencycheck:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleCheck(scope.row)"
            v-hasPermi="['civil:emergencycheck:edit']"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改“应急检查”对话框 -->
    <el-dialog :title="title" :visible.sync="openadd" width="650px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row>
        <el-col :span="12">
        <el-form-item label="隧道名称" prop="tunnelName">
          <el-input v-model="form.tunnelName" placeholder="请输入隧道名称" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="隧道编码" prop="tunnelId">
            <el-input v-model="form.tunnelId"  placeholder="请输入隧道编码" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="道路名称" prop="roadName">
            <el-input v-model="form.roadName" placeholder="请输入道路名称" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="道路编码" prop="roadId">
            <el-input v-model="form.roadId" placeholder="请输入道路编码" />
          </el-form-item>
        </el-col>
        </el-row>
          <el-form-item label="管养单位" prop="maintenanceOrganization" >
            <el-input v-model="form.maintenanceOrganization" placeholder="请输入管养单位" />
          </el-form-item>
        <el-form-item label="上次检查日期" prop="lastInspectionDate">
          <el-date-picker clearable
                          v-model="form.lastInspectionDate"
                          type="date"
                          value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="本次检查日期" prop="inspectionDate">
          <el-date-picker clearable
                          v-model="form.inspectionDate"
                          type="date"
                          value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-row>
        <el-col :span="12">
        <el-form-item label="里程桩号" prop="mileageNumber">
          <el-input v-model="form.mileageNumber" placeholder="请输入里程桩号" />
        </el-form-item>
        </el-col>
          <el-col :span="12">
            <el-form-item label="设施名称" prop="facilityName">
              <el-select v-model="form.facilityName" placeholder="请输入设施名称" clearable :style="{width: '100%'}">
                <el-option v-for="(item, index) in fieldfacility" :key="index" :label="item.label"
                           :value="item.value" :disabled="item.disabled"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="检查位置" prop="defectLocation">
          <el-input v-model="form.defectLocation" placeholder="请输入检查位置" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="检查内容" prop="examinationContent">
          <el-input v-model="form.examinationContent" placeholder="请输入检查内容" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="状况描述" prop="positionDescribe">
          <el-select v-model="form.positionDescribe" placeholder="请选择状况描述" clearable :style="{width: '100%'}">
            <el-option v-for="(item, index) in fieldpositionDescribe" :key="index" :label="item.label"
                       :value="item.value" :disabled="item.disabled"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="状况值" prop="positionNumber">
          <el-input v-model="form.positionNumber" placeholder="请输入状况值" />
        </el-form-item>
        <el-form-item label="上传图片">
          <image-upload v-model="form.picture"/>
        </el-form-item>
        <el-row>
        <el-form-item label="检查人员" prop="inspection">
          <el-input v-model="form.inspection" placeholder="请输入检查人员" />
        </el-form-item>
        <el-form-item label="记录人" prop="record">
          <el-input v-model="form.record" placeholder="请输入记录人" />
        </el-form-item>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--查看应急检查内容对话框-->
   <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-col :span="12">
            <el-form-item label="隧道名称" >
              <el-input v-model="form.tunnelName" v-bind:disabled="true"/>
            </el-form-item>
          </el-col>
        <el-col :span="12">
            <el-form-item label="隧道编码" >
              <el-input v-model="form.tunnelId" v-bind:disabled="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="道路名称" >
              <el-input v-model="form.roadName"  v-bind:disabled="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="道路编码" >
              <el-input v-model="form.roadId" v-bind:disabled="true" />
            </el-form-item>
          </el-col>
        <el-col>
        <el-form-item label="管养单位" >
          <el-input v-model="form.maintenanceOrganization" v-bind:disabled="true" />
        </el-form-item>
        </el-col>
        <el-col>
        <el-form-item label="上次检查日期" >
          <el-date-picker clearable
                          v-model="form.lastInspectionDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          v-bind:disabled="true">
          </el-date-picker>
        </el-form-item>
        </el-col>
        <el-col>
        <el-form-item label="本次检查日期" >
          <el-date-picker clearable
                          v-model="form.inspectionDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          v-bind:disabled="true">
          </el-date-picker>
        </el-form-item>
        </el-col>
        <el-col>
        <el-form-item label="里程桩号" >
          <el-input v-model="form.mileageNumber" v-bind:disabled="true" />
        </el-form-item>
        <el-form-item label="设施名称" >
          <el-input v-model="form.facilityName" v-bind:disabled="true" />
        </el-form-item>
        <el-form-item label="检查位置" >
          <el-input v-model="form.defectLocation"  v-bind:disabled="true"/>
        </el-form-item>
        <el-form-item label="检查内容" >
          <el-input v-model="form.examinationContent" v-bind:disabled="true" />
        </el-form-item>
        <el-form-item label="状况描述">
          <el-input v-model="form.positionDescribe" v-bind:disabled="true" />
        </el-form-item>
        <el-form-item label="状况值" >
          <el-input v-model="form.positionNumber" v-bind:disabled="true" />
        </el-form-item>
          <el-form-item label="上传图片">
            <image-upload v-model="form.picture"  v-bind:disabled="true"/>
          </el-form-item>
        <el-form-item label="检查人员">
          <el-input v-model="form.inspection" v-bind:disabled="true" />
        </el-form-item>
        <el-form-item label="记录人" >
          <el-input v-model="form.record" v-bind:disabled="true"/>
        </el-form-item>
        </el-col>
      </el-form>
     <div slot="footer" class="dialog-footer">
       <el-button @click="cancel">取消查看</el-button>
     </div>
    </el-dialog>
  </div>
</template>


<script>
import { listCheck, getCheck, delCheck, addCheck, updateCheck, pictureUp} from "@/api/civil/emergencycheck";

export default {
  name: "Check",
  data() {
    return {
      //自动上传
      autoUpload:true,
      //模型数据，用于上传图片完成后图片预览
      imageUrl:null,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      checkList: [],
      // 弹出层标题
      title: "",
      // 是否显示增加或修改的弹出层
      openadd: false,
      //是否显示产看的弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        tunnelName: null,
        tunnelId: null,
        roadName: null,
        roadId: null,
        maintenanceOrganization: null,
        lastInspectionDate: null,
        inspectionDate: null,
        mileageNumber: null,
        facilityName: null,
        defectLocation: null,
        examinationContent: null,
        positionDescribe: null,
        positionNumber: null,
        picture: null,
        inspection: null,
        record: null
      },
      // 表单参数
      form: {},
      //技术状况描述
      fieldpositionDescribe: [{
        "label": "洞口状况值判断为0",
        "value": "完好，无破坏现象"
      }, {
        "label": "洞口状况值判断为1",
        "value": "山体及岩体、挡土墙、护坡等有轻微裂缝产生，排水设施存在轻微破坏"
      },{
        "label": "洞口状况值判断为2",
        "value": "山体及岩体裂缝发育，存在滑坡、崩塌的初步迹象，坡面树木或电线杆轻微倾斜，挡土墙、护坡等产生开裂、变形，土石零星掉落，排水设施存在一定裂损、阻塞"
      }, {
        "label": "洞口状况值判断为3",
        "value": "山体及岩体严重开裂，坡面树木或电线杆明显倾斜，挡土墙、护坡等产生严重开裂、明显的永久变形，墙角或坡面有土石堆积，排水设施完全堵塞、破坏，排水功能失效"
      },{
        "label": "洞口状况值判断为4",
        "value": "山体及岩体有明显而严重的滑动、崩塌现象，挡土墙、护坡断裂、外倾失稳、部分倒塌，坡面树木或电线杆倾倒等"
      },{
        "label": "洞门状况值判断为0",
        "value": "完好，无破坏现象"
      },{
        "label": "洞门状况值判断为1",
        "value": "墙身存在轻微的开裂、起层、剥落"
      },{
        "label": "洞口状况值判断为2",
        "value": "墙身结构局部开裂，墙身轻微倾斜、沉陷或错台，壁面轻微渗水，尚未妨害交通"
      },{
        "label": "洞口状况值判断为3",
        "value": "墙身结构严重开裂、错台﹔边墙出现起层、剥落，混凝土块可能掉落或已有掉落;钢筋外露、受到锈蚀，墙身有明显倾斜、沉陷或错台趋势，璧面严重渗水（挂冰)，将会妨害交通"
      },{
        "label": "洞口状况值判断为4",
        "value": "洞门结构大范围开裂、砌体断裂、混凝土块可能掉落或已有掉落;墙身出现部分倾倒、垮塌，存在喷水或大面积挂冰等，已妨碍交通"
      },{
        "label": "衬砌状况值判断为0",
        "value": "结构无裂损、变形和背后空洞"
      },{
        "label": "衬砌状况值判断为1",
        "value": "出现变形、位移、沉降和裂缝，但无发展或已停止发展"
      },{
        "label": "衬砌状况值判断为2",
        "value": "出现变形、位移、沉降和裂缝,发展缓慢，边墙衬砌背后存在空隙，有扩大的可能"
      },{
        "label": "衬砌状况值判断为3",
        "value": "出现变形、位移、沉降，裂缝密集，出现剪切性裂缝,发展速度较快;边墙处衬砌压裂，导致起层、剥落，边墙混凝土有可能掉下"
      },{
        "label": "衬砌状况值判断为4",
        "value": "衬砌结构发生明显的永久变形，裂缝密集，出现剪切性裂缝，裂缝深度贯穿衬砌混凝土，并且发展快速;"
      },{
        "label": "路面状况值判断为0",
        "value": "路面完好"
      },{
        "label": "路面状况值判断为1",
        "value": "路面有浸湿、轻微裂缝、落物等，引起使用者轻微不舒适感"
      },{
        "label": "路面状况值判断为2",
        "value": "路面有局部的沉陷、隆起、坑洞、表面剥落、露骨、破损、裂缝，轻微积水，引起使用者明显的不舒适感，可能会影响行车安全"
      },{
        "label": "路面状况值判断为3",
        "value": "路面出现较大面积的沉陷、隆起、坑洞、表面剥落、露骨、破损、裂缝、积水严重等，影响行车安全;抗滑系数过低引起车辆打滑"
      },{
        "label": "路面状况值判断为4",
        "value": "路面出现大面积的明显沉陷、隆起、坑洞，路面板严重错台、断裂、表面剥落、露骨、破损、裂缝,出现漫水、结冰或堆冰，严重影响交通安全"
      },{
        "label": "检修道状况值判断为0",
        "value": "护栏、路缘石及检修道面板均完好"
      },{
        "label": "检修道状况值判断为1",
        "value": "护栏变形，路缘石或检修道面板少量缺角、缺损，金属有局部锈蚀，尚未影响其使用功能"
      },{
        "label": "检修道状况值判断为2",
        "value": "护栏变形损坏，螺栓松动、扭曲，金属表面锈蚀，部分路缘石或检修道面板缺损、开裂，部分功能丧失，可能会影响行人和交通安全"
      },{
        "label": "检修道状况值判断为3",
        "value": "护栏倒伏、严重损坏,侵入限界，路缘石或检修道面板缺损开裂或缺失严重，原有功能丧失，影响行人和交通安全"
      },{
        "label": "排水设施状况值判断为0",
        "value": "设施完好，排水功能正常"
      },{
        "label": "排水设施状况值判断为1",
        "value": "结构有轻微破损，但排水功能正常"
      },{
        "label": "排水设施状况值判断为2",
        "value": "轻微淤积，结构有破损，暴雨季节出现溢水，可能会影响交通安全"
      },{
        "label": "排水设施状况值判断为3",
        "value": "严重淤积，结构较严重破损，溢水造成路面局部积水、结冰，影响行车安全"
      },{
        "label": "排水设施状况值判断为4",
        "value": "完全阻塞，结构严重破损，溢水造成路面积水漫流、大面积结冰，严重影响行车安全"
      },{
        "label": "吊顶及预埋件状况值判断为0",
        "value": "吊顶完好"
      },{
        "label": "吊顶及预埋件状况值判断为1",
        "value": "存在轻微变形、破损、浸水，尚未妨碍交通"
      },{
        "label": "吊顶及预埋件状况值判断为2",
        "value": "吊顶破损、开裂、滴水，吊杆等预埋件锈蚀，尚未影响交通安全"
      },{
        "label": "吊顶及预埋件状况值判断为3",
        "value": "吊顶存在较严重的变形、破损，出现涌流、挂冰，吊杆等预埋件严重锈蚀，可能影响交通安全"
      },{
        "label": "吊顶及预埋件状况值判断为4",
        "value": "吊顶严重破损、开裂甚至掉落，出现喷涌水、严重挂冰，各种预埋件和悬吊件严重锈蚀或断裂"
      },{
        "label": "内装饰物状况值判断为0",
        "value": "内装饰完好"
      },{
        "label": "内装饰物状况值判断为1",
        "value": "个别内装饰板或瓷砖变形、破损，不影响交通"
      },{
        "label": "内装饰物状况值判断为2",
        "value": "部分内装饰板或瓷砖变形、破损、脱落，对交通安全有影响"
      },{
        "label": "内装饰物状况值判断为3",
        "value": "大面积内装饰板或瓷砖变形、破损、脱落，严重影响行车安全"
      },{
        "label": "交通标志、标线状况值判断为0",
        "value": ""
      },{
        "label": "交通标志、标线状况值判断为1",
        "value": "完好"
      },{
        "label": "交通标志、标线状况值判断为2",
        "value": "存在脏污、不完整，尚未妨碍交通"
      },{
        "label": "交通标志、标线状况值判断为3",
        "value": "存在脏污、部分脱落、缺失，可能会影响交通安全"
      },{
        "label": "交通标志、标线状况值判断为4",
        "value": "大部分存在脏污、脱落、缺失，影响行车安全"
      },
      ],
      fieldfacility: [{
        "label": "洞口",
        "value": "洞口"
      }, {
        "label": "洞门",
        "value": "洞门"
      },{
        "label": "衬砌",
        "value": "衬砌"
      },{
        "label": "路面",
        "value": "路面"
      },{
        "label": "检修道",
        "value": "检修道"
      },{
        "label": "排水设施",
        "value": "排水设施"
      },{
        "label": "吊顶及预埋件",
        "value": "吊顶及预埋件"
      },{
        "label": "装饰物",
        "value": "装饰物"
      }, {
        "label": "交通标志/标线",
        "value": "交通标志/标线"
      }
      ],
      // 表单校验
      rules: {
        tunnelName:[
          {required:true, message:"隧道名称为必填项", trigger:"blur"}
          ],
        tunnelId:[
          {required:true, message:"隧道编码为必填项", trigger:"blur"}
        ],
        roadName:[
          {required:true, message:"道路名称为必填项", trigger:"blur"}
        ],
        roadId:[
          {required:true, message:"道路编码为必填项", trigger:"blur"}
        ],
        maintenanceOrganization:[
          {required:true, message:"管养单位为必填项", trigger:"blur"}
        ],
        lastInspectionDate:[
          {required:true, message:"上次检查日期为必填项", trigger:"blur"}
        ],
        inspectionDate:[
          {required:true, message:"本次检查日期为必填项", trigger:"blur"}
        ],
        mileageNumber:[
          {required:true, message:"里程桩号为必填项", trigger:"blur"}
        ],
        facilityName:[
          {required:true, message:"设施名称为必填项", trigger:"blur"}
        ],
        defectLocation:[
          {required:true, message:"检查位置为必填项", trigger:"blur"}
        ],
        examinationContent:[
          {required:true, message:"检查内容为必填项", trigger:"blur"}
        ],
        positionDescribe:[
          {required:true, message:"状况描述为必填项", trigger:"blur"}
        ],
        positionNumber:[
          {required:true, message:"状况值为必填项", trigger:"blur"},
          { pattern: /^([0-4])$/, message: '状况值为0-4的整数'}
        ],
        inspection:[
          {required:true, message:"请填写检查人员姓名", trigger:"blur"}
        ],
        record:[
          {required:true, message:"请填写记录人员姓名", trigger:"blur"}
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {

    //文件上传成功后的钩子，response为服务端返回的值，file为当前上传的文件封装成的js对象
      handleAvatarSuccess(response, file) {
      this.imageUrl = "http://rbaqvoug4.hn-bkt.clouddn.com"+response.data;
      this.$message({
        message: response.message,
        type: response.flag ? 'success' : 'error'
      });
      //设置模型数据（图片名称），后续提交ajax请求时会提交到后台最终保存到数据库
      this.formData.img = response.data;
    },

    //上传图片之前执行
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;
      if (!isJPG) {
        this.$message.error('上传现场图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传现场图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    },

    /** 查询应急检查列表 */
    getList() {
      this.loading = true;
      listCheck(this.queryParams).then(response => {
        this.checkList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.openadd = false;
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        emergencyCheckId: null,
        tunnelName: null,
        tunnelId: null,
        roadName: null,
        roadId: null,
        maintenanceOrganization: null,
        lastInspectionDate: null,
        inspectionDate: null,
        mileageNumber: null,
        facilityName: null,
        defectLocation: null,
        examinationContent: null,
        positionDescribe: null,
        positionNumber: null,
        picture: null,
        inspection: null,
        record: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.emergencyCheckId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.openadd = true;
      this.title = "添加应急检查记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const emergencyCheckId = row.emergencyCheckId || this.ids
      getCheck(emergencyCheckId).then(response => {
        this.form = response.data;
        this.openadd = true;
        this.title = "修改应急检查记录";
      });
    },
    /** 查看按钮操作 */
    handleCheck(row) {
      this.reset();
      const emergencyCheckId = row.emergencyCheckId || this.ids
      getCheck(emergencyCheckId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "查看应急期检查记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.emergencyCheckId != null) {
            updateCheck(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.openadd = false;
              this.getList();
            });
          } else {
            addCheck(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.openadd = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const emergencyCheckIds = row.emergencyCheckId || this.ids;
      this.$modal.confirm('是否确认删除定期检查记录编号为"' + emergencyCheckIds + '"的数据项？').then(function() {
        return delCheck(emergencyCheckIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('civil/emergencycheck/export', {
        ...this.queryParams
      }, `check_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>

<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
  .datatable {
    position: relative;
    box-sizing: border-box;
    -webkit-box-flex: 1;
    width: 100%;
    max-width: 100%;
    font-size: 14px;
    color: rgb(96, 98, 102);
    overflow: hidden;
    flex: 1 1 0%;
  }
  .datatable td, .datatable th {
    padding: 12px 0;
    min-width: 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    text-overflow: ellipsis;
    vertical-align: middle;
    position: relative;
    text-align: left;
  }
</style>
